/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

.treeView {
  --tree-row-toggle-button-color: #888;
  --tree-row-toggle-button-active-color: var(--grey-60);
  --selected-tree-row-toggle-button-color: #fff;
  --selected-tree-row-toggle-button-active-color: rgb(255 255 255 / 0.7);

  display: flex;
  flex: 1;
  flex-flow: column nowrap;
  border-top: 1px solid var(--grey-30);
  cursor: default;
  user-select: none;
}

@media (forced-colors: active) {
  .treeView {
    --tree-row-toggle-button-color: ButtonText;
    --tree-row-toggle-button-active-color: SelectedItem;
    --selected-tree-row-toggle-button-color: SelectedItemText;
    --selected-tree-row-toggle-button-active-color: ButtonText;
  }
}

.treeViewRow,
.treeViewHeader {
  display: flex;
  flex-flow: row nowrap;
  justify-content: flex-start;
  white-space: nowrap;
}

.treeViewRowScrolledColumns {
  align-items: center;
}

.treeViewHeader {
  height: 15px;
  padding: 4px 0;
  border-bottom: 1px solid var(--grey-30);
  background: white;
}

.treeViewHeaderMainColumn {
  flex: 1;
}

.treeViewContextMenu {
  display: flex;
  flex: 1;
}

.treeViewBody {
  position: relative;
  z-index: 0;
  overflow: auto;
  flex: 1;
  line-height: 16px;
  outline: 0;
  will-change: scroll-position;
}

.treeViewBodyInnerWrapper {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  min-width: 100%;
  flex-flow: row nowrap;
}

.treeViewBodyInner0 {
  position: sticky;
  z-index: 2;
  left: 0;
}

.treeViewBodyInner1 {
  /* This allows the right column to expand more than its content, so that the
  * background always extends to the right edge. */
  flex-grow: 1;
}

.treeViewBodyInner {
  overflow: hidden;
  background: white;
}

.treeViewHeaderColumn {
  position: relative;
  line-height: 15px;
  white-space: nowrap;
}

.treeViewFixedColumn {
  overflow: hidden;
  text-overflow: ellipsis;
}

.treeViewColumnDivider {
  display: flex;
  width: 20px;
  flex: none;
  align-items: stretch;
  justify-content: center;
  margin-right: -5px;
  margin-left: -5px;
}

.treeViewColumnDivider.isResizable,
.treeView.isResizingColumns {
  cursor: col-resize;
}

.treeViewColumnDivider::before {
  border-right: 1px solid var(--grey-30);
  content: '';
}

.treeViewColumnDivider.isResizable::before {
  width: 1px;
  border-left: 1px solid var(--grey-30);
}

.treeViewHeaderColumn.treeViewFixedColumn {
  /* The fixed columns in the row don't shrink because they're positioning using
   * position: sticky, therefore we prevent shrinking for the columns in the
   * header too. */
  flex: none;
}

.treeBadge,
.backtraceBadge {
  display: inline-block;
  overflow: hidden;
  width: 12px;
  height: 12px;
  margin-right: 2px;
  color: transparent;
  vertical-align: -2px;
}

.treeRowIndentSpacer {
  flex-shrink: 0;
}

.treeViewAppendageColumn {
  margin-left: 10px;
  opacity: 0.6;
}

.treeViewRow.even {
  background-color: #fff;
}

.treeViewRow.odd {
  background-color: #f5f5f5;
}

/* Note that `isRightClicked` is present before `isSelected` so that it can be overriden. */
.treeViewRow.isRightClicked {
  background-color: var(--blue-50-a30);
}

.treeViewRow.isSelected {
  background-color: var(--grey-30);
  color: black;
}

.treeViewMainColumn.dim {
  opacity: 0.7;
}

/* stylelint-disable order/properties-order, declaration-block-no-duplicate-properties, value-keyword-case */
.treeViewBody:focus .treeViewRow.isSelected {
  /* Fallback for browsers that don't support SelectedItem */
  background-color: Highlight;
  color: HighlightText;

  /* Safari's non-standard SelectedItem equivalent (until SelectedItem is implemented, https://bugs.webkit.org/show_bug.cgi?id=230007 ) */
  /* stylelint-disable declaration-property-value-no-unknown */
  background-color: -apple-system-selected-content-background;
  color: -apple-system-alternate-selected-text;
  /* stylelint-enable declaration-property-value-no-unknown */

  /* The new standard color */
  background-color: SelectedItem;
  color: SelectedItemText;
}
/* stylelint-enable order/properties-order, declaration-block-no-duplicate-properties, value-keyword-case */

.treeViewBody:focus .treeViewRow.isSelected a {
  color: inherit;
}

.treeViewHighlighting {
  padding: 1px 0;
  border-radius: 2px;

  /* This negative margin enlarges the background to the top, so that it fully
  * covers the underlying background. There's an underlying background when the
  * line is selected. */
  margin: -1px 0;
  background: #cbe8fe;
  box-shadow:
    0 0 0 0.5px rgb(0 0 0 / 0.05),
    0 1px 1px rgb(0 0 0 / 0.3);
  color: #000;
}

.treeRowToggleButton {
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-right: 4px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 8px solid;
  margin-left: 8px;
  color: var(--tree-row-toggle-button-color);

  /* Opt-out of forced colors so the transparent borders aren't turned into opaque ones */
  forced-color-adjust: none;
}

.treeRowToggleButton.expanded {
  border-top: 8px solid;
  border-right: 5px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 5px solid transparent;
  margin-top: 5px;
  margin-right: 5px;
  margin-left: 5px;
}

.treeRowToggleButton:active:hover {
  color: var(--tree-row-toggle-button-active-color);
}

.treeViewBody:focus .treeViewRow.isSelected > .treeRowToggleButton {
  color: var(--selected-tree-row-toggle-button-color);
}

.treeViewBody:focus
  .treeViewRow.isSelected
  > .treeRowToggleButton:active:hover {
  color: var(--selected-tree-row-toggle-button-active-color);
}

.treeRowToggleButton.leaf {
  visibility: hidden;
}
